package com.cenluan.log4j;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.apache.log4j.PropertyConfigurator;

/**
 * 初始化监听器，通过properties文件配置log4j
 * 
 * @author peak
 * 
 */
public class InitializeListener implements ServletContextListener {

	public void contextInitialized(ServletContextEvent sce) {
		String filePath = sce.getServletContext().getRealPath(
				"/WEB-INF/log4j.properties");
		// 通过properties文件配置log4j
		PropertyConfigurator.configure(filePath);
	}

	public void contextDestroyed(ServletContextEvent sce) {
		// do nothing

	}

}
